home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / basic / mildred / lha / landtest6.lha / LandTest6.ascii < prev    next >
Text File  |  1999-05-24  |  21KB  |  705 lines

  1. .Demo
  2. WBStartup
  3.  
  4. DEFTYPE.w
  5.  
  6. Pic$="shape25tiny.IFF" ; 10 onwards
  7. Pic2$="shape17tiny.IFF"
  8. Pic3$="shape16tiny.IFF"
  9. Pic4$="shape19tiny.IFF"
  10. Land$="Land17.iff"
  11. DoLand=True
  12. Sky$="Sky39.iff" ;2;3;4;6;9;10;12;16;19;22
  13. DoSky=True
  14. #Objects=150  ;25;55;150;280;400
  15. DoObjects=True
  16. #ObjWidth=32  ;128;64;32;16;8
  17. #ObjHeight=32 ;64;64;32;16;8
  18. #StarsPerSpeed=15
  19. DoStars=False
  20. DoRainbow=True
  21.  
  22. *ScrVP.ViewPort=0
  23. IsAGA.b=True ; Defaults to AGA
  24. Dim PlanarBuf.l(2) ; Base address of planar memory to output c2p to (allowed up to triple buffers)
  25.  
  26. PrefDisplayID.l=$0 ; Default ModeID (Pal:LowRes, or promotes to DoublePal:LowRes)
  27. PrefDisplayWidth.w=320 ; Default Width
  28. PrefDisplayHeight.w=240 ; Default Height
  29. PrefDisplayBuffering.b=3 ; 1..3. 1=Singlebuffered, 2=Doublebuffered, 3=Triplebuffered
  30. PrefDisplayMethod.b=1 ; 0=WritePixelArray8/WriteChunkyPixels, 1=MBlockScroll, 2=WritePixelArray(CGFX)
  31. PrefCGFXLock.b=True ; Wether when Method=1, CGFX LockBitmap will be attempted for safety and to get base address
  32. OSVersion.w=ExecVersion
  33.  
  34. #DTAG_DISP=$80000000
  35. #DTAG_DIMS=$80001000
  36. #DTAG_MNTR=$80002000
  37. #DTAG_NAME=$80003000
  38. #LBMI_BASEADDRESS=$84001007
  39. #DIPF_IS_FOREIGN=$80000000
  40. #DIPF_IS_ECS=$00000010
  41. #DIPF_IS_AGA=$00010000
  42.  
  43. Function.b CheckLib{Lib$,LibVer}
  44. ;Returns wether a specific library is available or not
  45.   *lib.l=OpenLibrary_(&Lib$,LibVer)
  46.   If *lib
  47.     CloseLibrary_ *lib
  48.     Function Return True
  49.   Else
  50.     Function Return False
  51.   EndIf
  52. End Function
  53.  
  54. CGFXAvail.b=CheckLib{"cybergraphics.library",0}
  55. If Joyb(0)=0 AND Joyb(1)=0 AND CGFXAvail=False Then Goto SkipSMR
  56.  
  57. NEWTYPE.SMode
  58.   DID.l
  59.   DWidth.l
  60.   DHeight.l
  61.   DDepth.w
  62.   DType.w
  63. End NEWTYPE
  64.  
  65. DEFTYPE.Hook myhook ; The hook for ASL tag as &myhook
  66. myhook\h_Entry=?hook
  67. MOVE.l a5,globalbase
  68. funcret.l=0
  69.  
  70. Dim SMRtags.TagItem(17)
  71. SMRtags(0)\ti_Tag=#ASLSM_InitialLeftEdge,160 ; X coord of requester
  72. SMRtags(1)\ti_Tag=#ASLSM_InitialTopEdge,0 ; Y coord of requester
  73. SMRtags(2)\ti_Tag=#ASLSM_InitialWidth,300 ; Width of requester
  74. SMRtags(3)\ti_Tag=#ASLSM_InitialHeight,400 ; Height of requester
  75. SMRtags(4)\ti_Tag=#ASLSM_InitialDisplayID,$21000 ; Default ModeID (Pal:LowRes)
  76. SMRtags(5)\ti_Tag=#ASLSM_InitialDisplayDepth,8 ; Default depth (8-bit usually)
  77. SMRtags(6)\ti_Tag=#ASLSM_InitialDisplayWidth,PrefDisplayWidth
  78. SMRtags(7)\ti_Tag=#ASLSM_InitialDisplayHeight,PrefDisplayHeight
  79. SMRtags(8)\ti_Tag=#ASLSM_InitialOverscanType,1 ; Default overscan type (Text)
  80. SMRtags(9)\ti_Tag=#ASLSM_InitialInfoOpened,1 ; Info window?
  81. SMRtags(10)\ti_Tag=#ASLSM_InitialInfoLeftEdge,350 ; X coord of info window
  82. SMRtags(11)\ti_Tag=#ASLSM_InitialInfoTopEdge,50 ; Y coord of info window
  83. SMRtags(12)\ti_Tag=#ASLSM_DoDepth,0 ; Depth gadget? (Generally NO for chunky 8-bit)
  84. SMRtags(13)\ti_Tag=#ASLSM_DoOverscanType,0 ; Overscan gadget?
  85. SMRtags(14)\ti_Tag=#ASLSM_DoWidth,0 ; Width gadget?
  86. SMRtags(15)\ti_Tag=#ASLSM_DoHeight,0 ; Height gadget?
  87. SMRtags(16)\ti_Tag=#ASLSM_FilterFunc,&myhook ; Address of callback hook routine
  88. SMRtags(17)\ti_Tag=#TAG_DONE,0
  89.  
  90. *sreq.SMode=0
  91. *sreq=AllocAslRequest_(2,&SMRtags(0)\ti_Tag)
  92. ok.b=AslRequest_(*sreq,&SMRtags(0)\ti_Tag)
  93.  
  94. If ok<>0
  95.   PrefDisplayID.l=*sreq\DID
  96.   PrefDisplayWidth.w=*sreq\DWidth
  97.   PrefDisplayHeight.w=*sreq\DHeight
  98. EndIf
  99. If (*sreq) Then FreeAslRequest_(*sreq)
  100.  
  101. Goto SkipSMR
  102.  
  103. ;*************************************************************************
  104. ; This is the statement that the hook will call.  Put the label before
  105. ; the statement you want to jump to.
  106. Runerrsoff
  107. hook_jump:
  108. Statement hook{*dahook.Hook, modeID.l, *smr.ScreenModeRequester}
  109.   ; We're inside the hook, and supposedly we should be able to do whatever
  110.   ; we want.
  111.   ; Filter modeID's here
  112.   SHARED funcret.l
  113.   DEFTYPE.DisplayInfo DisInfoBuf
  114.   DEFTYPE.DimensionInfo DimInfoBuf
  115.   DEFTYPE.MonitorInfo MonInfoBuf
  116.   DEFTYPE.NameInfo NamInfoBuf
  117.   ;Refer to Includes/Graphics/DisplayInfo.h or view newtypes
  118.   IDhandle.l=FindDisplayInfo_(modeID)
  119.   GetDisplayInfoData_ IDhandle,&DisInfoBuf,SizeOf.DisplayInfo,#DTAG_DISP,0
  120.   GetDisplayInfoData_ IDhandle,&DimInfoBuf,SizeOf.DimensionInfo,#DTAG_DIMS,0
  121.   GetDisplayInfoData_ IDhandle,&MonInfoBuf,SizeOf.MonitorInfo,#DTAG_MNTR,0
  122.   GetDisplayInfoData_ IDhandle,&NamInfoBuf,SizeOf.NameInfo,#DTAG_NAME,0
  123.   ;Do tests. True=Mode is valid, False=mode is invalid.
  124.   ;See newtypes for DisplayInfo,DimensionInfo,MonitorInfo and NameInfo for things to further test
  125.   If DimInfoBuf\MaxDepth<>8
  126.     ;No true-colour modes, only 8-bit
  127.     funcret=False
  128.   Else
  129.     If DimInfoBuf\TxtOScan\MaxX>320-1
  130.       ;No hires modes
  131.       funcret=False
  132.     Else
  133.       If DimInfoBuf\TxtOScan\MaxY<240-1 OR DimInfoBuf\TxtOScan\MaxY>256-1
  134.         ;Not too short
  135.         funcret=False
  136.       Else
  137.         funcret=True
  138.       EndIf
  139.     EndIf
  140.   EndIf
  141. End Statement
  142.  
  143. ;**********************
  144. ; Hook
  145. Macro goto_hook
  146.   JSR `1+6
  147. End Macro
  148.  
  149. globalbase: Dc.l 0
  150.  
  151. hook: ;This hook is called by the filter hook callback from screenmode requester, per item
  152. ; Store registers
  153. MOVEM.l   d1-d7/a0-a6,-(a7) ; Not d0!
  154.  
  155. ; Put parameters into dregs ready for a statement
  156. MOVE.l    a0,d0
  157. MOVE.l    a1,d1
  158. MOVE.l    a2,d2
  159.  
  160. ; Get global variable base
  161. MOVE.l    globalbase,a5
  162.  
  163. ; Goto hook statement
  164. !goto_hook{hook_jump}
  165.  
  166. GetReg d0,funcret ; return accept/discard
  167.  
  168. ; Restore registers
  169. MOVEM.l   (a7)+,d1-d7/a0-a6 ; Not d0!
  170.  
  171. RTS
  172. ;**********************
  173.  
  174. Runerrson
  175. .SkipSMR
  176.  
  177. Function.b InitDisplay{Title$}
  178. ;Creates a display for AGA or Graphics-Card output
  179. ;Title$=The screen title (not displayed)
  180.   SHARED PrefDisplayWidth,PrefDisplayHeight,PrefDisplayBuffering
  181.   SHARED *ScrVP,PrefDisplayID,IsAGA,PlanarBuf(),CGFXAvail
  182.  
  183.   ;Setup a test screen
  184.   Dim ScrTags.TagItem(13)
  185.   Rect.Rectangle\MinX=0,0,320,240 ; For test
  186.   ScrTags(0)\ti_Tag=#SA_Width,320 ; For test
  187.   ScrTags(1)\ti_Tag=#SA_Height,240; For test
  188.   ScrTags(2)\ti_Tag=#SA_Depth,8
  189.   ScrTags(3)\ti_Tag=#SA_DisplayID,PrefDisplayID
  190.   ScrTags(4)\ti_Tag=#SA_Type,$F
  191.   ScrTags(5)\ti_Tag=#SA_Quiet,True
  192.   ScrTags(6)\ti_Tag=#SA_ShowTitle,False
  193.   ScrTags(7)\ti_Tag=#SA_Behind,True
  194.   ScrTags(8)\ti_Tag=#SA_DClip,&Rect ; For test
  195.   ScrTags(9)\ti_Tag=#SA_Exclusive,False
  196.   ScrTags(10)\ti_Tag=#SA_Draggable,False
  197.   ScrTags(11)\ti_Tag=#SA_AutoScroll,False
  198.   ScrTags(12)\ti_Tag=#TAG_DONE,0
  199.   ScrTags(13)\ti_Tag=#TAG_DONE,0
  200.  
  201.   If CGFXAvail
  202.     IsAGA=1-(IsCyberModeID_(PrefDisplayID))
  203.   Else
  204.     ; Need to do a test
  205.     UsedChip.l=320*240 ; With test params (depth 8)
  206.     FreeChip.l=AvailMem_(#MEMF_CHIP)
  207.     Forbid_
  208.     If ScreenTags(0,Title$,&ScrTags(0))
  209.       NowChip.l=AvailMem_(#MEMF_CHIP)
  210.       Permit_
  211.       If FreeChip-NowChip<UsedChip
  212.         IsAGA=False
  213.       Else
  214.         IsAGA=True
  215.       EndIf
  216.       VWait 5
  217.       Free Screen 0
  218.       VWait 5
  219.     Else
  220.       ; Failed to open, so resort to fixed AGA LowRes
  221.       Permit_
  222.       IsAGA=True
  223.       PrefDisplayID=0
  224.       PrefDisplayWidth=320
  225.       PrefDisplayHeight=240
  226.     EndIf
  227.   EndIf
  228.  
  229.   If IsAGA
  230.     PrefDisplayHeight=240
  231.     PrefDisplayWidth AND $FFC0 ; Multiples of 64 for AGA
  232.   Else
  233.     PrefDisplayWidth AND $FFF0 ; Multiples of 16 for graphics card
  234.   EndIf
  235.   ScrTags(0)\ti_Tag=#SA_Width,PrefDisplayWidth
  236.   Rect.Rectangle\MinX=0,0,PrefDisplayWidth,PrefDisplayHeight
  237.   ScrTags(8)\ti_Tag=#SA_DClip,&Rect
  238.  
  239.   If IsAGA
  240.     ; AGA display
  241.     ScrTags(1)\ti_Tag=#SA_Height,PrefDisplayHeight ; Seperate buffers
  242.     ScrTags(3)\ti_Tag=#SA_DisplayID,PrefDisplayID
  243.     Forbid_
  244.     For Loop.w=0 To PrefDisplayBuffering-1
  245.       If Loop=0 Then WFlags.l=$1900 Else WFlags.l=$800
  246.       If AvailMem_(#MEMF_CHIP)>=(PrefDisplayWidth*PrefDisplayHeight)+16
  247.         Memory.l=AllocMem((PrefDisplayWidth*PrefDisplayHeight)+16,$10002) ; Chipram bitmap
  248.         Memory=(Memory+16) AND $FFFFFFF0 ; Align for move16's
  249.         If Memory
  250.           CludgeBitMap Loop,PrefDisplayWidth,PrefDisplayHeight,8,Memory ; Depth 8
  251.           If Loop=0
  252.             ScrTags(12)\ti_Tag=#SA_BitMap,Addr BitMap(0)
  253.             If ScreenTags(0,Title$,&ScrTags(0))=0
  254.               Permit_
  255.               Function Return False
  256.             EndIf
  257.           EndIf
  258. If Window(Loop,0,0,PrefDisplayWidth,PrefDisplayHeight,WFlags,"",0,0)=0 Then Function Return False
  259.           Menus Off
  260.         Else
  261.           Permit_
  262.           Function Return False
  263.         EndIf
  264.       Else
  265.         Permit_
  266.         Function Return False
  267.       EndIf
  268.       PlanarBuf(Loop)=Memory
  269.     Next Loop
  270.     Permit_
  271.   Else
  272.     ; Graphics-card display
  273.     ScrTags(1)\ti_Tag=#SA_Height,PrefDisplayHeight*PrefDisplayBuffering
  274.     If ScreenTags(0,Title$,&ScrTags(0))
  275.       For Loop.w=0 To PrefDisplayBuffering-1
  276.         If Loop=0 Then WFlags.l=$1900 Else WFlags.l=$800
  277. If Window(Loop,0,PrefDisplayHeight*Loop,PrefDisplayWidth,PrefDisplayHeight,WFlags,"",0,0)=0 Then Function Return False
  278.         Menus Off
  279.         ScreensBitMap 0,Loop
  280.         *TmpBmp.bitmap=Addr BitMap(Loop)
  281.         Offset.l=*TmpBmp\_ebwidth*(PrefDisplayHeight*Loop)
  282.         For DLoop.w=0 To 8-1 ; Depth of 8
  283.           *TmpBmp\_data[DLoop]=*TmpBmp\_data[DLoop]+Offset
  284.         Next DLoop
  285.       Next Loop
  286.     Else
  287.       Function Return False
  288.     EndIf
  289.   EndIf
  290.  
  291.   If Peek.l(Addr Screen(0))
  292.     DEFTYPE.DimensionInfo DimInfoBuf
  293.     GetDisplayInfoData_ FindDisplayInfo_(PrefDisplayID) AND $FFFFFFFF,&DimInfoBuf,SizeOf.DimensionInfo,#DTAG_DIMS,0
  294.     PrefDisplayLeft.w=((DimInfoBuf\TxtOScan\MaxX)-PrefDisplayWidth)/2
  295.     PrefDisplayTop.w=((DimInfoBuf\TxtOScan\MaxY)-PrefDisplayHeight)/2
  296.     *Scr.Screen=Peek.l(Addr Screen(0))
  297.     *ScrVP=ViewPort(0)
  298.     *ScrVP\DxOffset=PrefDisplayLeft,PrefDisplayTop
  299.     ScrollVPort_ *ScrVP
  300.     RethinkDisplay_
  301.     Menus Off
  302.     If *ScrVP\DHeight<>PrefDisplayHeight
  303.       Forbid_
  304.       *Scr\Height=PrefDisplayHeight ; Enforce y clipping
  305.       Permit_
  306.     EndIf
  307.     ScreenToFront_ *Scr
  308.     Function Return True
  309.   Else
  310.     Function Return False
  311.   EndIf
  312. End Function
  313.  
  314. .Main
  315. If CGFXAvail=False AND PrefDisplayMethod=2 Then PrefDisplayMethod=0
  316. If InitDisplay{"Game"}=False Then Goto Finish
  317. If PrefDisplayMethod=0 AND OSVersion<40
  318.   MBitmap 5,PrefDisplayWidth,PrefDisplayHeight ; Temporary bitmap to allow WPA8 instead of WPL8's
  319. EndIf
  320.  
  321. InitBank 0,2880*60,$10000
  322. CludgeBitMap 3,2880,60,8,Bank(0)
  323. LoadBitMap 3,Land$
  324. MBitmap 2,2880,60
  325. MPlanar16ToBitmap 2,Bank(0)
  326. InitBank 0,320*240,$10000
  327. CludgeBitMap 3,320,240,8,Bank(0)
  328. MGetaShape 0,1120,0,16,27
  329. MBitmap 1,PrefDisplayWidth,170 ; 150 gfx card, 164 AGA
  330. MBitmap 0,PrefDisplayWidth+#ObjWidth,PrefDisplayHeight+#ObjHeight+#ObjHeight
  331. InitShape 0,16,1,2
  332. WPointer 0
  333.  
  334. If IsAGA Then Mc2pWindow 0,PrefDisplayWidth,PrefDisplayHeight,PrefDisplayWidth+#ObjWidth,PrefDisplayWidth,PrefDisplayHeight
  335.  
  336. InitPalette 1,256
  337. InitPalette 0,256
  338. Cls 0
  339. LoadBitMap 3,Pic$,0
  340. MShape 1,#ObjWidth,#ObjHeight
  341. MPlanar16ToShape 1,Bank(0),#ObjWidth,#ObjHeight,PrefDisplayWidth,PrefDisplayHeight
  342. MMakeCookie 1
  343. For c=0 To 31
  344.   CopyColour 0,1,c,64+c
  345. Next c
  346. For c=1 To 31
  347.   MReMapShape c,64+c,1
  348. Next c
  349. Cls 0
  350. LoadBitMap 3,Pic2$,0
  351. MShape 2,#ObjWidth,#ObjHeight
  352. MPlanar16ToShape 2,Bank(0),#ObjWidth,#ObjHeight,PrefDisplayWidth,PrefDisplayHeight
  353. MMakeCookie 2
  354. For c=0 To 31
  355.   CopyColour 0,1,c,64+32+c
  356. Next c
  357. For c=1 To 31
  358.   MReMapShape c,64+32+c,2
  359. Next c
  360. Cls 0
  361. LoadBitMap 3,Pic3$,0
  362. MShape 3,#ObjWidth,#ObjHeight
  363. MPlanar16ToShape 3,Bank(0),#ObjWidth,#ObjHeight,PrefDisplayWidth,PrefDisplayHeight
  364. MMakeCookie 3
  365. For c=0 To 31
  366.   CopyColour 0,1,c,128+c
  367. Next c
  368. For c=1 To 31
  369.   MReMapShape c,128+c,3
  370. Next c
  371. Cls 0
  372. LoadBitMap 3,Pic4$,0
  373. MShape 4,#ObjWidth,#ObjHeight
  374. MPlanar16ToShape 4,Bank(0),#ObjWidth,#ObjHeight,PrefDisplayWidth,PrefDisplayHeight
  375. MMakeCookie 4
  376. For c=0 To 31
  377.   CopyColour 0,1,c,128+32+c
  378. Next c
  379. For c=1 To 31
  380.   MReMapShape c,128+32+c,4
  381. Next c
  382.  
  383. Cls 0
  384. LoadBitMap 3,Sky$,0
  385. MPlanar16ToBitmap 1,Bank(0),PrefDisplayWidth,150,PrefDisplayWidth,PrefDisplayHeight
  386. For c=64 To 127
  387.   MReMap c,128+c,1
  388.   CopyColour 0,1,c,128+c
  389. Next c
  390. For c=0 To 63
  391.   CopyColour 0,1,c,c
  392. Next c
  393.  
  394. NumberOfShapes.w=4
  395. LoadRGB32_ *ScrVP,Peek.l(Addr Palette(1))
  396.  
  397. NEWTYPE.xy
  398.   x.w
  399.   y.w
  400. End NEWTYPE
  401. Dim pos.xy(#Objects)
  402. Dim pos2.xy(#Objects)
  403. Dim direction.xy(#Objects)
  404. For obj=1 To #Objects
  405.   pos(obj)\x=Rnd(2239-#ObjWidth)
  406.   pos(obj)\y=Rnd(PrefDisplayHeight-#ObjHeight-60-14-16)+8
  407.   Repeat
  408.     direction(obj)\x=Rnd(8)-4
  409.   Until direction(obj)\x<>0
  410.   direction(obj)\y=Rnd(6)-3
  411. Next obj
  412.  
  413. NEWTYPE.xyq
  414.   x.q
  415.   y.q
  416. End NEWTYPE
  417. Dim star1.xyq(#StarsPerSpeed)
  418. Dim star2.xyq(#StarsPerSpeed)
  419. Dim star3.xyq(#StarsPerSpeed)
  420. Dim star4.xyq(#StarsPerSpeed)
  421. Dim star5.xyq(#StarsPerSpeed)
  422. For s=1 To #StarsPerSpeed
  423.   star1(s)\x=Rnd(319)
  424.   star1(s)\y=Rnd(120)
  425.   star2(s)\x=Rnd(319)
  426.   star2(s)\y=Rnd(100)
  427.   star3(s)\x=Rnd(319)
  428.   star3(s)\y=Rnd(80)
  429.   star4(s)\x=Rnd(319)
  430.   star4(s)\y=Rnd(60)
  431.   star5(s)\x=Rnd(319)
  432.   star5(s)\y=Rnd(40)
  433. Next s
  434.  
  435. speedsetting.q=1 ; Global speed multiplier
  436. xpos.q=0
  437. xaccelerate.q=1*speedsetting
  438. xmomentum.q=0
  439. xairresistance.q=0;.1*speedsetting
  440. xmaxspeed.q=16*speedsetting
  441. ypos.q=(PrefDisplayHeight-69)/2
  442. yaccelerate.q=0.7*speedsetting
  443. ymomentum.q=0
  444. ymaxspeed.q=8*speedsetting
  445. ytopdampen.q=1.9
  446. ybottomdampen.q=1.65
  447. ygravity.q=0.15;*speedsetting
  448.  
  449. NEWTYPE.OffsetList
  450.   LineWidth.w
  451.   X1Offset.w
  452.   X2Offset.w
  453.   ModuloOffset.w
  454. End NEWTYPE
  455. Dim rows.OffsetList(47)
  456. Dim rowsq.q(47)
  457.  
  458. .Loop
  459. MParticleFormat 0
  460. MBitmapOrigin 0,#ObjWidth/2,#ObjHeight
  461. MBitmapWrap 0,On
  462. intcnt=0
  463. SetInt 5
  464.   intcnt+1
  465. End SetInt
  466. buf.b=0
  467. cnt.b=0
  468. its.l=0
  469. ResetTimer
  470.  
  471. While Joyb(0)=0 AND Joyb(1)=0
  472.  
  473.   jh=JHoriz(1)
  474.   jv=JVert(1)
  475.  
  476.   xmomentum+(xaccelerate*jh)
  477.   ymomentum+(yaccelerate*jv)
  478.  
  479.   ymomentum+ygravity
  480.   If xmomentum>0
  481.     xmomentum-xairresistance
  482.     If xmomentum<0 Then xmomentum=0
  483.   Else
  484.     xmomentum+xairresistance
  485.     If xmomentum>0 Then xmomentum=0
  486.   EndIf
  487.  
  488.   If xmomentum>xmaxspeed Then xmomentum=xmaxspeed
  489.   If xmomentum<-xmaxspeed Then xmomentum=-xmaxspeed
  490.   If ymomentum>ymaxspeed Then ymomentum=ymaxspeed
  491.   If ymomentum<-ymaxspeed Then ymomentum=-ymaxspeed
  492.  
  493.   xpos+xmomentum
  494.   ypos+ymomentum
  495.  
  496.   If ypos<0
  497.     ymomentum=-ymomentum/ytopdampen
  498.     ypos=0
  499.   EndIf
  500.   If ypos>PrefDisplayHeight-40
  501.     ymomentum=-ymomentum/ybottomdampen
  502.     ypos=PrefDisplayHeight-40
  503.   EndIf
  504.  
  505.   If xpos<0 Then xpos+2240
  506.   If xpos>=2240 Then xpos-2240
  507.  
  508.   If DoSky=False
  509.     MBitmapClip 0,0,0,PrefDisplayWidth,PrefDisplayHeight-60-32,On
  510.     MCls 192;0
  511.     MBitmapClip 0,Off
  512.   Else
  513.     MBlockScroll 0,0,PrefDisplayWidth,PrefDisplayHeight-60-32,0,0,1
  514.   EndIf
  515.  
  516.   If DoRainbow=False
  517.     MBoxF 0,PrefDisplayHeight-60-32,319,PrefDisplayHeight-61,0
  518.   Else
  519.     c=1
  520.     MBoxF 0,PrefDisplayHeight-60-32,319,PrefDisplayHeight-61-14,0
  521.     For yy=PrefDisplayHeight-75 To PrefDisplayHeight-61
  522.       MBoxF 0,yy,319,yy,c
  523.       c+4
  524.     Next yy
  525.     xx.q=xpos/7
  526.     For b=1 To 8
  527.       MBoxF 320-xx,PrefDisplayHeight-62,320-xx+3,PrefDisplayHeight-61,30
  528.       xx+40
  529.       If xx>319 Then xx-320
  530.     Next b
  531.     MDrawingMode MAddMode
  532.     MBoxF 139,PrefDisplayHeight-92,180,PrefDisplayHeight-61,5
  533.     MBox 139,PrefDisplayHeight-92,180,PrefDisplayHeight-61,7
  534.     MDrawingMode MColourMode
  535.   EndIf
  536.  
  537.   If DoStars
  538.     MAddXYToParticlesQ &star1(1)\x,#StarsPerSpeed,-(xmomentum/60),0
  539.     MAddXYToParticlesQ &star2(1)\x,#StarsPerSpeed,-(xmomentum/50),0
  540.     MAddXYToParticlesQ &star3(1)\x,#StarsPerSpeed,-(xmomentum/40),0
  541.     MAddXYToParticlesQ &star4(1)\x,#StarsPerSpeed,-(xmomentum/30),0
  542.     MAddXYToParticlesQ &star5(1)\x,#StarsPerSpeed,-(xmomentum/20),0
  543.     MParticleFormat -1
  544.     MBitmapClip 1,On
  545.     MWrapXParticles &star1(1)\x,#StarsPerSpeed
  546.     MWrapXParticles &star2(1)\x,#StarsPerSpeed
  547.     MWrapXParticles &star3(1)\x,#StarsPerSpeed
  548.     MWrapXParticles &star4(1)\x,#StarsPerSpeed
  549.     MWrapXParticles &star5(1)\x,#StarsPerSpeed
  550.     MBitmapClip 1,Off
  551.     MPlotParticles &star1(1)\x,#StarsPerSpeed,192+14-Rnd(12)
  552.     MPlotParticles &star2(1)\x,#StarsPerSpeed,192+20-Rnd(12)
  553.     MPlotParticles &star3(1)\x,#StarsPerSpeed,192+26-Rnd(12)
  554.     MPlotParticles &star4(1)\x,#StarsPerSpeed,192+32-Rnd(12)
  555.     MPlotParticles &star5(1)\x,#StarsPerSpeed,192+38-Rnd(12)
  556.     MParticleFormat 0
  557.   EndIf
  558.  
  559.   If DoLand
  560.     MScroll 160+xpos,47,PrefDisplayWidth,13,0,PrefDisplayHeight-13,2
  561.     mult.q=1.0
  562.     width.q=2240
  563.     widthadd.q=(2240-320)/47
  564.     For yy=46 To 0 Step -1
  565.       rowsq(yy)=1280-(width LSR 1)+(xpos*mult) ; 1280=1120+320-160
  566.       width-widthadd
  567.       mult-0.01825
  568.       ;mult=width/2240
  569.     Next yy
  570.     rows(0)\LineWidth=320,Int(rowsq(0)),0,0
  571.     For yy=1 To 46
  572.       rows(yy)\LineWidth=320,Int(rowsq(yy))-Int(rowsq(yy-1)),0,0
  573.     Next yy
  574.     MScroll 0,0,320,47,0,PrefDisplayHeight-60,2,&rows(0)\LineWidth
  575.   EndIf
  576.  
  577.   If DoObjects
  578.     MAddToParticles &pos(1)\x,#Objects,&direction(1)\x
  579.     For obj=1 To #Objects
  580.       If pos(obj)\x<0 Then pos(obj)\x+2240
  581.       If pos(obj)\x>=2240 Then pos(obj)\x-2240
  582.       If pos(obj)\y<8 OR pos(obj)\y>PrefDisplayHeight-16-#ObjHeight Then direction(obj)\y=-direction(obj)\y
  583.     Next obj
  584.     For obj=1 To #Objects
  585.       pos2(obj)\x=pos(obj)\x/7
  586.       pos2(obj)\y=PrefDisplayHeight-92+(pos(obj)\y/7)
  587.     Next obj
  588.     MAddXYToParticles &pos2(1)\x,#Objects,320-(xpos/7)-180,0
  589.     MBitmapClip 0,0,0,PrefDisplayWidth,PrefDisplayHeight,On
  590.     MWrapXParticles &pos2(1)\x,#Objects
  591.     MBitmapClip 0,Off
  592.   ;  MPlotParticles &pos2(1)\x,#Objects,255
  593.     ww=(#ObjWidth/7)-1
  594.     hh=(#ObjHeight/7)-1
  595.   ;  MDrawingMode MAddMode
  596.     For p=1 To #Objects
  597. ;      MBoxF pos2(p)\x,pos2(p)\y,pos2(p)\x+ww,pos2(p)\y+hh,240+Rnd(15);10
  598.       MZoomShapeToBitmap 3,3,7,7,pos2(p)\x,pos2(p)\y,ww,hh,False,(p MOD NumberOfShapes)+1
  599. ;      MMaskScrollShapeToBitmap 16,16,4,5,pos2(p)\x,pos2(p)\y,(p MOD NumberOfShapes)+1
  600.     Next p
  601.     MDrawingMode MColourMode
  602.     MPlot 160,PrefDisplayHeight-91+(ypos/7),255
  603.     MPlot 160,PrefDisplayHeight-90+(ypos/7),255
  604.     For obj=1 To #Objects
  605.       If pos(obj)\x>xpos-#ObjWidth AND pos(obj)\x<xpos+PrefDisplayWidth;-#ObjWidth+#ObjWidth
  606.         MBlit (obj MOD NumberOfShapes)+1,pos(obj)\x-xpos,pos(obj)\y
  607.       EndIf
  608.     Next obj
  609.     MBlit 0,152,ypos
  610.   EndIf
  611.  
  612. .Display
  613.   If IsAGA
  614.     Mc2p MBitmapPtr(0),PlanarBuf(buf)
  615.     If PrefDisplayBuffering>1
  616.       ShowBitMap buf
  617.       buf+1
  618.       If buf=PrefDisplayBuffering Then buf=0
  619.     EndIf
  620.   Else
  621.     *RP0.RastPort=RastPort(0)
  622.     Select PrefDisplayMethod
  623.  
  624.       Case 0 ; WritePixelArray8
  625.       If PrefDisplayBuffering>1
  626.         *RP1.RastPort=RastPort(Min(PrefDisplayBuffering-1,cnt+1))
  627.         If OSVersion<40
  628.           MUseBitmap 5
  629.           MBlockScroll 0,0,PrefDisplayWidth,PrefDisplayHeight,0,0,0 ; From window in modulo bitmap, to nonmodulo bitmap
  630.           MUseBitmap 0
  631.           WritePixelArray8_ *RP1,0,0,PrefDisplayWidth-1,PrefDisplayHeight-1,MBitmapPtr(5),0
  632.         Else
  633.           WriteChunkyPixels_ *RP1,0,0,PrefDisplayWidth-1,PrefDisplayHeight-1,MBitmapPtr(0),MBitmapWidth(0)
  634.         EndIf
  635.         ClipBlit_ *RP1,0,0,*RP0,0,0,PrefDisplayWidth,PrefDisplayHeight,$C0
  636.         If PrefDisplayBuffering=3 Then cnt=1-cnt ; Toggle output buffer
  637.       Else
  638.         If OSVersion<40
  639.           MUseBitmap5
  640.           MBlockScroll 0,0,PrefDisplayWidth,PrefDisplayHeight,0,0,0 ; From window in modulo bitmap, to nonmodulo bitmap
  641.           MUseBitmap 0
  642.           WritePixelArray8_ *RP0,0,0,PrefDisplayWidth-1,PrefDisplayHeight-1,MBitmapPtr(5),0
  643.         Else
  644.           WriteChunkyPixels_ *RP0,0,0,PrefDisplayWidth-1,PrefDisplayHeight-1,MBitmapPtr(0),MBitmapWidth(0)
  645.         EndIf
  646.       EndIf
  647.  
  648.       Case 1 ; MBlockScroll
  649.       If CGFXAvail AND PrefCGFXLock
  650.         Dim CGFXTags.TagItem(1)
  651.         CGFXData.l=0
  652.         CGFXTags(0)\ti_Tag=#LBMI_BASEADDRESS,&CGFXData
  653.         CGFXTags(1)\ti_Tag=#TAG_DONE,0
  654.         LockHandle.l=LockBitMapTagList_(*RP0\BitMap,&CGFXTags(0))
  655.         MCludgeBitmap 4,PrefDisplayWidth,PrefDisplayHeight*PrefDisplayBuffering,CGFXData
  656.       Else
  657.         MCludgeBitmap 4,PrefDisplayWidth,PrefDisplayHeight*PrefDisplayBuffering,*RP0\BitMap\Planes
  658.       EndIf
  659.       If PrefDisplayBuffering>1
  660.         *RP1.RastPort=RastPort(Min(PrefDisplayBuffering-1,cnt+1))
  661.         MBlockScroll 0,0,PrefDisplayWidth,PrefDisplayHeight,0,PrefDisplayHeight+(cnt*PrefDisplayHeight),0 ; From modulo bitmap
  662.         ClipBlit_ *RP1,0,0,*RP0,0,0,PrefDisplayWidth,PrefDisplayHeight,$C0
  663.         If PrefDisplayBuffering=3 Then cnt=1-cnt ; Toggle output buffer
  664.       Else
  665.         MBlockScroll 0,0,PrefDisplayWidth,PrefDisplayHeight,0,0,0 ; From modulo bitmap
  666.       EndIf
  667.       MUseBitmap 0
  668.       If CGFXAvail AND (LockHandle<>0) AND PrefCGFXLock Then UnLockBitMap_ LockHandle
  669.  
  670.       Case 2 ; CGFXWriteChunkyPixels
  671.       If PrefDisplayBuffering>1
  672.         *RP1.RastPort=RastPort(Min(PrefDisplayBuffering-1,cnt+1))
  673.         WritePixelArray_ MBitmapPtr(0),0,0,MBitmapWidth(0),*RP1,0,0,PrefDisplayWidth,PrefDisplayHeight,#RECTFMT_LUT8
  674.         ClipBlit_ *RP1,0,0,*RP0,0,0,PrefDisplayWidth,PrefDisplayHeight,$C0
  675.         If PrefDisplayBuffering=3 Then cnt=1-cnt ; Toggle output buffer
  676.       Else
  677.         WritePixelArray_ MBitmapPtr(0),0,0,MBitmapWidth(0),*RP0,0,0,PrefDisplayWidth,PrefDisplayHeight,#RECTFMT_LUT8
  678.       EndIf
  679.     End Select
  680.   EndIf
  681.  
  682. ;  If intcnt<=2 Then VWait Else intcnt=0 ; only wait for 25fps if faster
  683.   its+1
  684. Wend
  685.  
  686. ;Report
  687. t=Timer
  688. t=Max(t,1)
  689. its=Max(its,1)
  690. a.q=50.0/(t/its)
  691. WBenchToFront_
  692. WbToScreen 1
  693. Window 2,16,16,300,40,0,"Test results",1,0
  694. WindowOutput 2
  695. NPrint a," frames per second"
  696. NPrint " "
  697. NPrint "Press mouse/joy button..."
  698. VWait 20
  699. Repeat
  700. Until Joyb(0)<>0 OR Joyb(1)<>0
  701.  
  702. Finish:
  703. End
  704.  
  705.